layui.define(["table", "form", "admin", "upload"], function (exports) {
    var $ = layui.$,
        table = layui.table;

    table.render({
        elem: "#LAY-active-manage",
        url: "/admin/report/get_active",
        cols: [
            [
                {field: "id", width: 80, title: "ID", sort: true},
                {field: "order_no", width: 80, title: "订单号", sort: true},
                {
                    field: "",
                    width: 180,
                    title: "用户昵称",
                    templet: function (d) {
                        return d.user ? d.user.nick_name : '';
                    },
                },
                {
                    field: "",
                    minWidth: 20,
                    title: "订单类型",
                    templet: function (d) {
                        if (d.type == 0) {
                            return "购买宝石";
                        } else if (d.type == 1) {
                            return "开通贵族";
                        }
                        return "其它";
                    },
                },
                {field: "pay_amount", title: "订单金额", width: 100},
                {field: "amount", title: "应付金额", width: 100},
                {field: "gold", minWidth: 80, title: "购买宝石"},
                {field: "gold_added", minWidth: 80, title: "赠送宝石"},
                {field: "out_trade_no", minWidth: 80, title: "支付单号"},
                {
                    field: "",
                    minWidth: 20,
                    title: "支付渠道",
                    templet: function (d) {
                        if (d.pay_channel == 1) {
                            return "微信";
                        } else if (d.pay_channel == 2) {
                            return "支付宝";
                        } else if (d.pay_channel == 3) {
                            return "苹果支付";
                        } else if (d.pay_channel == 5) {
                            return "人工";
                        }
                        return "其他";
                    },
                },
                {field: "create_time", width: 170, title: "下单时间"},
                {
                    field: "",
                    minWidth: 20,
                    title: "支付状态",
                    templet: function (d) {
                        if (d.pay_status == 1) {
                            return '<span class="layui-badge layui-bg-green">支付成功</span>';
                        } else if (d.pay_status == 2) {
                            return '<span class="layui-badge layui-bg-orange">支付取消</span>';
                        } else if (d.pay_status == 3) {
                            return '<span class="layui-badge layui-bg-black">支付失败</span>';
                        }
                        return '<span class="layui-badge layui-bg-red">等待支付</span>';
                    },
                },
            ],
        ],
        page: true,
        limit: 20,
        height: "full-140",
        text: "对不起，加载出现异常！",
        even: true,
    });
    table.render({
        elem: "#LAY-chat-manage",
        url: "/admin/report/get_chat",
        cols: [
            [
                {field: "uid", width: 100, title: "主播ID"},
                {
                    field: "nick_name",
                    width: 100,
                    title: "主播昵称",
                },
                {field: "live_id", minWidth: 100, title: "直播间编号"},
                {field: "title", minWidth: 100, title: "直播间标题"},
                {
                    field: "",
                    minWidth: 150,
                    title: "直播类别",
                    templet: function (d) {
                        if (d.category == 1) {
                            return "娱乐";
                        } else {
                            return "体育";
                        }
                    },
                },
                {field: "hot", width: 100, title: "热度值"},
                {field: "avg_duration", title: "直播时长(分钟)", width: 130},
                {
                    field: "new_fans_count",
                    minWidth: 100,
                    title: "新增粉丝数",
                },
                {
                    field: "",
                    minWidth: 100,
                    title: "总粉丝数",
                    templet: function (d) {
                        return d.fans_count ?? 0;
                    },
                },
                {
                    field: "message_count",
                    minWidth: 100,
                    title: "新增消息数",
                },
                {
                    field: "",
                    minWidth: 100,
                    title: "直播状态",
                    templet: function (d) {
                        return d.status == 1
                            ? '<span class="layui-badge layui-bg-green">直播中</span>'
                            : '<span class="layui-badge layui-bg-red">已结束</span>';
                    },
                },
                {
                    field: "viewer_count",
                    minWidth: 100,
                    title: "观看人次",
                },
                {
                    field: "online_peak",
                    minWidth: 100,
                    title: "人数峰值",
                },
                {
                    field: "",
                    minWidth: 150,
                    title: "礼物总数/宝石",
                    templet: function (d) {
                        return d.gift_num + "/" + d.gift_total_value;
                    },
                },
                {
                    field: "",
                    minWidth: 150,
                    title: "钻石总数/钻石",
                    templet: function (d) {
                        return d.gift_diamond_total_num + "/" + d.gift_diamond_total_price;
                    },
                },
                {
                    field: "anthor_total_income",
                    minWidth: 100,
                    title: "主播收益",
                },
            ],
        ],
        page: true,
        limit: 20,
        height: "full-140",
        text: "对不起，加载出现异常！",
        even: true,
    });
    table.render({
        elem: "#LAY-chat-summary",
        url: "/admin/report/get_summary",
        cols: [
            [
                {
                    field: "",
                    width: 100,
                    title: '<span class="layui-badge">新增粉丝</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.new_fans +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    width: 100,
                    title: '<span class="layui-badge">直播场次</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.live_count +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">新增消息</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.message_count +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">观看人次</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.viewer_count +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">人数峰值</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.online_peak +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">热度值</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' + d.hot + "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">礼物数/总价值</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.gift_num +
                            "/" +
                            d.gift_total_value +
                            "</span>"
                        );
                    },
                },
                {
                    field: "",
                    minWidth: 100,
                    title: '<span class="layui-badge">主播收益</span>',
                    templet: function (d) {
                        return (
                            '<span class="layui-badge layui-bg-green">' +
                            d.anchor_income +
                            "</span>"
                        );
                    },
                },
            ],
        ],
        text: "对不起，加载出现异常！",
        even: true,
    });
    table.render({
        elem: "#LAY-anchor-manage",
        url: "/admin/report/get_anchor",
        cols: [
            [
                {field: "nick_name", width: 120, title: "主播名称"},
                {field: "anchorid", title: "房间ID", width: 140},
                {field: "times", title: "总直播场次", width: 100},
                {field: "duration", title: "直播总时长(分钟)", width: 150},
                {field: "avg_duration", title: "平均直播时长", width: 120},
                {
                    field: "",
                    width: 90,
                    title: "分成比例",
                    templet: function (d) {
                        return d.sharing_ratio + "%";
                    },
                },
                {field: "gift_num_people", width: 100, title: "送礼总人数"},
                {field: "avg_gift_num_people", width: 120, title: "平均送礼人数"},
                {field: "gift_profit", width: 100, title: "送礼总价值"},
                {field: "avg_gift_profit", width: 120, title: "平均送礼价值"},
                {field: "anchor_income", width: 120, title: "主播总收益"},
                {field: "avg_anchor_income", width: 120, title: "平均主播收益"},
                {field: "barrage_time_count", width: 120, title: "总弹幕数量"},
                {
                    field: "avg_barrage_time_count",
                    width: 120,
                    title: "平均弹幕数量",
                },
                {field: "avg_new_fans_count", width: 120, title: "平均新增粉丝"},
                {field: "fans_count", width: 100, title: "总粉丝数"},
            ],
        ],
        page: true,
        limit: 20,
        height: "full-140",
        text: "对不起，加载出现异常！",
        even: true,
    });
    exports("report", {});
});
